home *** CD-ROM | disk | FTP | other *** search
/ Internet Publisher's Toolbox 2.0 / Internet Publisher's Toolbox.iso / internet / ntserver / wtsource / stoplist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-16  |  7.7 KB  |  487 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4. */
  5.  
  6. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  7.  
  8.  
  9. /* this is a set of utilities for maintaining a stoplist
  10.  * kind of a kludge.
  11.  *
  12.  * -brewster
  13.  */
  14.  
  15. #ifndef lint
  16. static char *RCSid = "$Header: /usr/users/freewais/FreeWAIS-0.1/ir/stoplist.c,v 1.1 1993/02/16 15:05:35 freewais Exp $";
  17. #endif
  18.  
  19. /* Change log:
  20.  * $Log: stoplist.c,v $
  21.  * Revision 1.1  1993/02/16  15:05:35  freewais
  22.  * Initial revision
  23.  *
  24.  * Revision 1.2  92/02/12  13:50:01  jonathan
  25.  * Added "$Log" so RCS will put the log message in the header
  26.  * 
  27.  * 
  28. */
  29.  
  30. #include "stoplist.h"
  31. #include "cutil.h"
  32. #include <string.h>
  33.  
  34. static char stoplist_filename[MAX_FILENAME_LEN];/* dgg */
  35. long    stoplist_pointer = 0;
  36. char   *stoplist[] = {
  37.     "a",
  38.     "about",
  39.     "above",
  40.     "according",
  41.     "across",
  42.     "actually",
  43.     "adj",
  44.     "after",
  45.     "afterwards",
  46.     "again",
  47.     "against",
  48.     "all",
  49.     "almost",
  50.     "alone",
  51.     "along",
  52.     "already",
  53.     "also",
  54.     "although",
  55.     "always",
  56.     "among",
  57.     "amongst",
  58.     "an",
  59.     "and",
  60.     "another",
  61.     "any",
  62.     "anyhow",
  63.     "anyone",
  64.     "anything",
  65.     "anywhere",
  66.     "are",
  67.     "aren't",
  68.     "around",
  69.     "as",
  70.     "at",
  71.     "b",
  72.     "be",
  73.     "became",
  74.     "because",
  75.     "become",
  76.     "becomes",
  77.     "becoming",
  78.     "been",
  79.     "before",
  80.     "beforehand",
  81.     "begin",
  82.     "beginning",
  83.     "behind",
  84.     "being",
  85.     "below",
  86.     "beside",
  87.     "besides",
  88.     "between",
  89.     "beyond",
  90.     "billion",
  91.     "both",
  92.     "but",
  93.     "by",
  94.     "c",
  95.     "can",
  96.     "can't",
  97.     "cannot",
  98.     "caption",
  99.     "co",
  100.     "co.",
  101.     "could",
  102.     "couldn't",
  103.     "d",
  104.     "did",
  105.     "didn't",
  106.     "do",
  107.     "does",
  108.     "doesn't",
  109.     "don't",
  110.     "down",
  111.     "during",
  112.     "e",
  113.     "each",
  114.     "eg",
  115.     "eight",
  116.     "eighty",
  117.     "either",
  118.     "else",
  119.     "elsewhere",
  120.     "end",
  121.     "ending",
  122.     "enough",
  123.     "etc",
  124.     "even",
  125.     "ever",
  126.     "every",
  127.     "everyone",
  128.     "everything",
  129.     "everywhere",
  130.     "except",
  131.     "f",
  132.     "few",
  133.     "fifty",
  134.     "first",
  135.     "five",
  136.     "for",
  137.     "former",
  138.     "formerly",
  139.     "forty",
  140.     "found", "",
  141.     "four",
  142.     "from",
  143.     "further",
  144.     "g",
  145.     "h",
  146.     "had",
  147.     "has",
  148.     "hasn't",
  149.     "have",
  150.     "haven't",
  151.     "he",
  152.     "he'd",
  153.     "he'll",
  154.     "he's",
  155.     "hence",
  156.     "her",
  157.     "here",
  158.     "here's",
  159.     "hereafter",
  160.     "hereby",
  161.     "herein",
  162.     "hereupon",
  163.     "hers",
  164.     "herself",
  165.     "him",
  166.     "himself",
  167.     "his",
  168.     "how",
  169.     "however",
  170.     "hundred",
  171.     "i",
  172.     "i'd",
  173.     "i'll",
  174.     "i'm",
  175.     "i've",
  176.     "ie",
  177.     "if",
  178.     "in",
  179.     "inc.",
  180.     "indeed",
  181.     "instead",
  182.     "into",
  183.     "is",
  184.     "isn't",
  185.     "it",
  186.     "it's",
  187.     "its",
  188.     "itself",
  189.     "j",
  190.     "k",
  191.     "l",
  192.     "last",
  193.     "later",
  194.     "latter",
  195.     "latterly",
  196.     "least",
  197.     "less",
  198.     "let",
  199.     "let's",
  200.     "like",
  201.     "likely",
  202.     "ltd",
  203.     "m",
  204.     "made",
  205.     "make",
  206.     "makes",
  207.     "many",
  208.     "maybe",
  209.     "me",
  210.     "meantime",
  211.     "meanwhile",
  212.     "might",
  213.     "million",
  214.     "miss",
  215.     "more",
  216.     "moreover",
  217.     "most",
  218.     "mostly",
  219.     "mr",
  220.     "mrs",
  221.     "much",
  222.     "must",
  223.     "my",
  224.     "myself",
  225.     "n",
  226.     "namely",
  227.     "neither",
  228.     "never",
  229.     "nevertheless",
  230.     "next",
  231.     "nine",
  232.     "ninety",
  233.     "no",
  234.     "nobody",
  235.     "none",
  236.     "nonetheless",
  237.     "noone",
  238.     "nor",
  239.     "not",
  240.     "nothing",
  241.     "now",
  242.     "nowhere",
  243.     "o",
  244.     "of",
  245.     "off",
  246.     "often",
  247.     "on",
  248.     "once",
  249.     "one",
  250.     "one's",
  251.     "only",
  252.     "onto",
  253.     "or",
  254.     "other",
  255.     "others",
  256.     "otherwise",
  257.     "our",
  258.     "ours",
  259.     "ourselves",
  260.     "out",
  261.     "over",
  262.     "overall",
  263.     "own",
  264.     "p",
  265.     "per",
  266.     "perhaps",
  267.     "q",
  268.     "r",
  269.     "rather",
  270.     "recent",
  271.     "recently",
  272.     "s",
  273.     "same",
  274.     "seem",
  275.     "seemed",
  276.     "seeming",
  277.     "seems",
  278.     "seven",
  279.     "seventy",
  280.     "several",
  281.     "she",
  282.     "she'd",
  283.     "she'll",
  284.     "she's",
  285.     "should",
  286.     "shouldn't",
  287.     "since",
  288.     "six",
  289.     "sixty",
  290.     "so",
  291.     "some",
  292.     "somehow",
  293.     "someone",
  294.     "something",
  295.     "sometime",
  296.     "sometimes",
  297.     "somewhere",
  298.     "still",
  299.     "stop",
  300.     "such",
  301.     "t",
  302.     "taking",
  303.     "ten",
  304.     "than",
  305.     "that",
  306.     "that'll",
  307.     "that's",
  308.     "that've",
  309.     "the",
  310.     "their",
  311.     "them",
  312.     "themselves",
  313.     "then",
  314.     "thence",
  315.     "there",
  316.     "there'd",
  317.     "there'll",
  318.     "there're",
  319.     "there's",
  320.     "there've",
  321.     "thereafter",
  322.     "thereby",
  323.     "therefore",
  324.     "therein",
  325.     "thereupon",
  326.     "these",
  327.     "they",
  328.     "they'd",
  329.     "they'll",
  330.     "they're",
  331.     "they've",
  332.     "thirty",
  333.     "this",
  334.     "those",
  335.     "though",
  336.     "thousand",
  337.     "three",
  338.     "through",
  339.     "throughout",
  340.     "thru",
  341.     "thus",
  342.     "to",
  343.     "together",
  344.     "too",
  345.     "toward",
  346.     "towards",
  347.     "trillion",
  348.     "twenty",
  349.     "two",
  350.     "u",
  351.     "under",
  352.     "unless",
  353.     "unlike",
  354.     "unlikely",
  355.     "until",
  356.     "up",
  357.     "upon",
  358.     "us",
  359.     "used",
  360.     "using",
  361.     "v",
  362.     "very",
  363.     "via",
  364.     "w",
  365.     "was",
  366.     "wasn't",
  367.     "we",
  368.     "we'd",
  369.     "we'll",
  370.     "we're",
  371.     "we've",
  372.     "well",
  373.     "were",
  374.     "weren't",
  375.     "what",
  376.     "what'll",
  377.     "what's",
  378.     "what've",
  379.     "whatever",
  380.     "when",
  381.     "whence",
  382.     "whenever",
  383.     "where",
  384.     "where's",
  385.     "whereafter",
  386.     "whereas",
  387.     "whereby",
  388.     "wherein",
  389.     "whereupon",
  390.     "wherever",
  391.     "whether",
  392.     "which",
  393.     "while",
  394.     "whither",
  395.     "who",
  396.     "who'd",
  397.     "who'll",
  398.     "who's",
  399.     "whoever",
  400.     "whole",
  401.     "whom",
  402.     "whomever",
  403.     "whose",
  404.     "why",
  405.     "will",
  406.     "with",
  407.     "within",
  408.     "without",
  409.     "won't",
  410.     "would",
  411.     "wouldn't",
  412.     "x",
  413.     "y",
  414.     "yes",
  415.     "yet",
  416.     "you",
  417.     "you'd",
  418.     "you'll",
  419.     "you're",
  420.     "you've",
  421.     "your",
  422.     "yours",
  423.     "yourself",
  424.     "yourselves",
  425.     "z", NULL
  426. };
  427.  
  428. long    nstops = 0;
  429. char  **stop_from_file = NULL;    /* dgg */
  430. char  **stop_ptr;        /* dgg */
  431. typedef char    (*charptr);
  432.  
  433. void stop_list_file (filename)
  434. char   *filename;
  435. {
  436.     strcpy (stoplist_filename, filename);
  437. }
  438.  
  439. void init_stop_list () {
  440. #ifdef BIO
  441.     if (nstops > 0 && stop_from_file != NULL) {/* dgg */
  442.     int     i;
  443.     for (i = 0; i < nstops; i++)
  444.         free (stop_from_file[i]);
  445.     free (stop_from_file);
  446.     nstops = 0;
  447.     }
  448. /* printf("init_stop_list: stoplist file is '%s'\n", stoplist_filename); */
  449.     if (stoplist_filename[0] != '\0') {
  450.     char    word[256];
  451.     FILE * fp;
  452.     fp = fopen (stoplist_filename, "r");
  453.     nstops = 1;
  454.     (void *) stop_from_file = malloc (nstops * sizeof (charptr));
  455.     while (fgets (word, 255, fp)) {
  456.         char   *cp = strstr (word, "\n");
  457.         if (cp != NULL)
  458.         *cp = '\0';
  459.         stop_from_file[nstops - 1] = malloc (strlen (word) + 1);
  460.         strcpy (stop_from_file[nstops - 1], word);
  461. /* printf("init_stop_list: word %d is '%s'\n", nstops, stop_from_file[nstops-1]); */
  462.         nstops++;
  463.         (void *) stop_from_file = realloc (stop_from_file, nstops * sizeof (charptr));
  464.     }
  465.     fclose (fp);
  466.     stop_from_file[nstops - 1] = NULL;
  467.     stop_ptr = stop_from_file;
  468. /* printf("init_stop_list: read %d stop words from '%s'\n", nstops-1, stoplist_filename); */
  469.     }
  470.     else 
  471. #endif
  472.         stop_ptr = stoplist;
  473.  
  474.     stoplist_pointer = 0;
  475. }
  476.  
  477.  
  478. char   *next_stop_word () {
  479.     /* returns NULL if all out */
  480.     if      (stop_ptr[stoplist_pointer] == NULL)
  481.             return (NULL);
  482.     else
  483.     return (stop_ptr[stoplist_pointer++]);
  484. }
  485.  
  486.  
  487.